package com.yanfan.zutai.controller;


import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.zutai.aop.SysInitData;
import com.yanfan.zutai.aop.SysInitUpdateData;
import com.yanfan.zutai.aop.SysQueryData;
import com.yanfan.zutai.domain.BMqttMessage;
import com.yanfan.zutai.service.IBMqttMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * mqtt上报日志Controller
 *
 * @author ruoyi
 * @date 2021-08-28
 */
@RestController
@RequestMapping("/synthesize/bMqttMessage")
public class BMqttMessageController extends BaseController {
    @Autowired
    private IBMqttMessageService bMqttMessageService;

    /**
     * 查询mqtt上报日志列表
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:list')")
    @GetMapping("/list")
    @SysQueryData
    public TableDataInfo list(BMqttMessage bMqttMessage) {
        startPage();
        List<BMqttMessage> list = bMqttMessageService.selectBMqttMessageList(bMqttMessage);
        return getDataTable(list);
    }

    /**
     * 导出mqtt上报日志列表
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:export')")
    @Log(title = "mqtt上报日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @SysQueryData
    public AjaxResult export(BMqttMessage bMqttMessage) {
        List<BMqttMessage> list = bMqttMessageService.selectBMqttMessageList(bMqttMessage);
        ExcelUtil<BMqttMessage> util = new ExcelUtil<BMqttMessage>(BMqttMessage.class);
        return util.exportExcel(list, "message");
    }

    /**
     * 获取mqtt上报日志详细信息
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bMqttMessageService.selectBMqttMessageById(id));
    }

    /**
     * 新增mqtt上报日志
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:add')")
    @Log(title = "mqtt上报日志", businessType = BusinessType.INSERT)
    @PostMapping
    @SysInitData
    public AjaxResult add(@RequestBody BMqttMessage bMqttMessage) {
        return toAjax(bMqttMessageService.insertBMqttMessage(bMqttMessage));
    }

    /**
     * 修改mqtt上报日志
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:edit')")
    @Log(title = "mqtt上报日志", businessType = BusinessType.UPDATE)
    @PutMapping
    @SysInitUpdateData
    public AjaxResult edit(@RequestBody BMqttMessage bMqttMessage) {
        return toAjax(bMqttMessageService.updateBMqttMessage(bMqttMessage));
    }

    /**
     * 删除mqtt上报日志
     */
    //@PreAuthorize("@ss.hasPermi('synthesize:bMqttMessage:remove')")
    @Log(title = "mqtt上报日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bMqttMessageService.deleteBMqttMessageByIds(ids));
    }
}
